Search
Other Articles Anywhere questions
Forum

{foreach}-loop strips html-code around first returned element

Ton van Loon's Avatar Ton van Loon
The {foreach}-loop strips html-code around first returned element in below code. In fact it strips anything I put before the first row:data-tag.
{article}
{if credits>0}
<div class="container">
  <div class="row">
    <div class="col-sm-12 rounded" style="color:#fff; background:#29ba52;padding:10px 10px 0px 10px" >
     <p><strong>Credits</strong></p>
    </div>
    <div class="col-sm-12" style="padding:10px 10px 10px 10px;>
    {foreach data="credits" separator=" | "}
    <strong>[row:creditsvoor]: </strong> [row:creditsaan] 
    {/foreach} 
    </div>
  </div>
</div>
{/if}
{/article}

Outcome:
Bewerking: Iris Kodde & Wietske Dotinga | Fotografie: Tanne van der Wal

Expected outcome:
Bewerking: Iris Kodde & Wietske Dotinga | Fotografie: Tanne van der Wal


Environment:
- J4.1.0
- AA 12.1.1PRO
Peter van Westen's Avatar Peter van Westen ADMIN
Do you have this online so I can take a look?
Please post a rating at the Joomla! Extensions Directory
Ton van Loon's Avatar Ton van Loon
www.sta-toneel.nl/index.php/beschikbare-...ddings-and-a-funeral

article id: 154

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
So the issue is that you are outputting custom fields. These are rendered through a layout and already contain a surrounding <div> tag.
If you then place <strong> around that, it will break the HTML structure (not valid).

If you only want to output the plain text of the custom field, so not rendering it through the layout, you need to tell Articles Anywhere to do that.
See: docs4.regularlabs.com/articlesanywhere/d...lain-text-raw-values
Please post a rating at the Joomla! Extensions Directory
Ton van Loon's Avatar Ton van Loon
If I understand it correctly, I have to add the ":text" suffix. But this results in not showing the contents at all.

Outcome:
Iris Kodde & Wietske Dotinga | : Tanne van der Wal

Expected outcome:
Bewerking: Iris Kodde & Wietske Dotinga | Fotografie: Tanne van der Wal

info: the [creditsvoor]-custom field is a list-field on a repeatable form, the [creditsaan]-customfield is a text-field on the same repeatable
{article}
{if credits>0}
<div class="container">
<div class="row">
<div class="col-sm-12 rounded" style="color:#fff; background:#29ba52;padding:10px 10px 0px 10px" >
<p><strong>Credits</strong></p>
</div>
<div class="col-sm-12" style="padding:10px 10px 10px 10px;>
{foreach data="credits" separator=" | "}
<strong>[row:creditsvoor:text]: </strong> [row:creditsaan] {/foreach} 
</div>
</div>
</div>
{/if}
{/article}
Peter van Westen's Avatar Peter van Westen ADMIN
Ah, I see what is messing things up: You are missing an ending quote in your HTML div:
<div class="col-sm-12" style="padding:10px 10px 10px 10px;>
Should be:
<div class="col-sm-12" style="padding:10px 10px 10px 10px;">
Please post a rating at the Joomla! Extensions Directory
Ton van Loon's Avatar Ton van Loon
Ouch..... Sorry!
Peter van Westen's Avatar Peter van Westen ADMIN
Or better yet:
<div class="col-sm-12 p-3">
Please post a rating at the Joomla! Extensions Directory
Ton van Loon's Avatar Ton van Loon
Thank you! Sofar I have not studied bootstrap enough. I still have to finish my HTML/CSS course from Jonas Schmedtmann on Udemy, up-next is bootstrap.
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription